package kuangshen.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @program: liangt
 * @description: 测试线程池
 * @author: liangt
 * @create: 2021-03-03 17:12
 */
public class TestPool {

    public static void main(String[] args) {
        //创建线程池
        ExecutorService executorService = Executors.newFixedThreadPool(10);

        //执行
        executorService.execute(()->{
            System.out.println(Thread.currentThread().getName());
        });
        executorService.execute(()->{
            System.out.println(Thread.currentThread().getName());
        });
        executorService.execute(()->{
            System.out.println(Thread.currentThread().getName());
        });
        executorService.execute(()->{
            System.out.println(Thread.currentThread().getName());
        });
        executorService.execute(()->{
            System.out.println(Thread.currentThread().getName());
        });

        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName());
        });
        //关闭线程池
        executorService.shutdown();;
    }
}
